import React from 'react';
import { Button } from 'antd';
import { CreateOpsWebApp } from '@/utils/fetch';

const request = CreateOpsWebApp();
// import { sendMsg } from '@/scripts/onlineNotice';

const Devtools = () => {
  // 加锁
  const handleLock = async () => {
    try {
      // storyId 取_id
      const res = await request.post('/tapd/story/isLock', { storyId: '6564057ad7c9ee4a4cce7f83' });
      console.log(res);
    } catch (err) {
      console.log(err);
    }
  };
  // 创建排期
  const handleSchedule = async () => {
    const params = {
      storyId: '6564057ad7c9ee4a4cce7f83',
      developOwner: '赵美阳',
      developEnv: 'dev',
      timeNodes: {
        reviewTime: '2023-11-28',
        jointTime: '2023-11-28',
        smokeTime: '2023-11-28',
        subTestTime: '2023-11-28',
        TestTime: '2023-11-28',
        acceptTime: '2023-11-28',
        onlineTime: '2023-11-28',
      },
      testArea: '测试范围',
      developerList: [
        {
          developerName: '赵美阳',
          developerId: '130221',
          taskList: [
            {
              taskType: 1,
              taskCost: '20',
              taskStartTime: '2023-11-28',
              taskEndTime: '2023-11-29',
            },
          ],
        },
      ],
    };
    try {
      const res = await request.post('/tapd/story/setSchedule', params);
      console.log(res);
    } catch (err) {
      console.log(err);
    }
  };

  const handleGetSchedule = async () => {
    try {
      const res = await request.get('/tapd/story/getSchedule', { storyId: '6564057ad7c9ee4a4cce7f83' });
      console.log(res);
    } catch (err) {
      console.log(err);
    }
  };

  const handlePullProjects = async () => {
    const res = await request.get('/gitlab/projects');
    console.log(res);
  };

  return (
    <div>
      <div>
        <Button
          onClick={() => {
            request.post('/gitlab/recentBranches');
          }}
        >
          定时任务检查主分支合并情况
        </Button>
      </div>
      <hr />
      <div>
        <Button>周三上线通知</Button>
      </div>
      <hr />
      <div>
        <Button
          onClick={() => {
            handleLock();
          }}
        >
          需求加锁
        </Button>
      </div>
      <hr />
      <div>
        <Button
          onClick={() => {
            handleSchedule();
          }}
        >
          创建排期
        </Button>
        <Button
          onClick={() => {
            handleGetSchedule();
          }}
        >
          获取排期
        </Button>
      </div>
      <hr />
      <div>
        <Button
          onClick={() => {
            handlePullProjects();
          }}
        >
          从gitlab更新最新数据入库
        </Button>
      </div>
      <hr />
      <div>
        <Button
          onClick={() => {
            request.get('/review/refresh');
          }}
        >
          刷新review排期
        </Button>
      </div>
      <hr />
      <div>
        <Button
          onClick={() => {
            request.post('/gitlab/mergeCounts');
          }}
        >
          检查每个人的未合并次数
        </Button>
      </div>
    </div>
  );
};

export default Devtools;
